




**********************************************************************************************************************************************
*Replication Package for “Judge Ideology and Corporate Tax Planning”

*This document describes the replication package for the JFQA paper titled “Judge Ideology and Corporate Tax Planning” by Travis Chow, Allen H. Huang, Kai Wai Hui, and Terry Shevlin.

*The file named pseudo_random1.do contains all the code used to construct the final sample and perform the empirical analyses. Each section is accompanied by a brief description of the procedures. Due to licensing restrictions, we cannot share the actual final sample data used in our regressions and analysis. Instead, we have provided a randomized version (pseudo_compustat_controls.dta) so that the code can be executed. Please note that results from the pseudo sample will not match those reported in the paper. In this pseudo sample, the variable pseudoid replaces the actual firm identifiers (gvkey).

*For enquiries, please contact Travis Chow (travischow@hku.hk).
**********************************************************************************************************************************************



**********************************
***Compustat Fundamental Annual***
**********************************

clear
use "C:\Users\Compustat", clear

drop costat curcd datafmt indfmt consol

gen datayear=year(datadate)
gen year=fyear

destring, replace

drop if cik==.
sort cik fyear
quietly by cik fyear: gen dup=cond(_N==1,0,_n)
drop if dup>=2
drop dup


*************************
***Construct Variables***
*************************

gen txww=txt
replace txfo=0 if txfo==. & txfed==txww
replace txfo=0 if txfo==. & pidom==pi
replace pifo=0 if pifo==. & pidom==pi
replace txfo=0 if pifo==. & txfed==txww

replace pifo=(pi-pidom) if pifo==. & pidom<. & pi<.
replace pidom=(pi-pifo) if pidom==. & pifo<. & pi<.
replace pi=(pidom+pifo) if pi==. & pifo<. & pidom<.

replace txfed=(txww-txfo) if txfed==. & txfo<. & txww<.
replace txfo=(txww-txfed) if txfo==. & txfed<. & txww<.
replace txww=txfed+txfo if txww==. & txfed<. & txfo<.

drop if at==.

sort gvkey fyear 

by gvkey: gen at_lag1=at[_n-1]
by gvkey: gen sale_lag1=sale[_n-1]
by gvkey: gen tlcf_lag1=tlcf[_n-1]

gen invt0=invt
replace invt0=0 if invt0==.
gen xrd0=xrd
replace xrd0=0 if xrd0==.
gen ppent0=ppent
replace ppent0=0 if ppent0==.
gen intan0=intan
replace intan0=0 if intan0==.
gen pifo0=pifo
replace pifo0=0 if pifo0==.
gen xad0=xad
replace xad0=0 if xad0==.
gen xsga0=xsga
replace xsga0=0 if xsga0==.
gen mii0=mii
replace mii0=0 if mii0==.
gen esub0=esub
replace esub0=0 if esub0==.

gen ln_at=ln(at)
gen mb=prcc_f*csho/ ceq
gen dltt_at=dltt/at_lag1
gen invt0_at=invt0/at_lag1
gen xrd0_at=xrd0/at_lag1
gen ppent0_at=ppent0/at_lag1
gen intan0_at=intan0/at_lag1
gen roa_oi=oibdp/at
gen pifo0_at=pifo0/at_lag1
gen fi0=!missing(pifo0) & pifo0>0
egen max_fi0=max(fi0), by(gvkey)
gen xad0_at=xad0/at_lag1
gen sale_growth=((sale-sale_lag1)/sale_lag1)
gen sale0_growth=sale_growth
replace sale0_growth=0 if sale_growth==.
gen xsga0_at=xsga0/at_lag1
gen nol0=0
replace nol0=1 if tlcf>0 & tlcf<.
replace tlcf=0 if tlcf==.
gen ch_nol=tlcf - tlcf_lag1
gen ch_nol0=ch_nol
replace ch_nol0=0 if ch_nol==.
gen ch_nol0_at=ch_nol0/at_lag1
gen esub0_at=esub0/at_lag1
gen mii0_at=mii0/at_lag1

gen pidom0=pidom
replace pidom0=pi if pidom0==. & pifo==.
replace pidom0=pi if pidom0==. & pifo==0
replace txdfed=0 if txdfed==.

gen fedtax=txfed+txdfed

gen fedetr=fedtax/pidom0
replace fedetr=. if missing(pidom0) | pidom0<=0

gen fedetr1=fedetr
replace fedetr1=0 if !missing(fedetr) & fedetr<0
replace fedetr1=1 if !missing(fedetr) & fedetr>1

gen fedetrww=fedtax/pi
replace fedetrww=. if missing(pi) | pi<0

gen fedetrww1=fedetrww
replace fedetrww1=0 if !missing(fedetrww) & fedetrww<0
replace fedetrww1=1 if !missing(fedetrww) & fedetrww>1

replace sich=sic if sich==.

gen sic3h=int(sich/10)
egen sic3hy=group(sic3h datayear)

gen sic2h=int(sich/100)
egen sic2hy=group(sic2h datayear)

gen fin=0
replace fin=1 if sic>=6000 & sic<=6999

*at_category (for IRS audit probability)
recode at (0/0.25=0.25) (0.25/1=1) (1/5=5) (5/10=10) (10/50=50) (50/100=100) (100/250=250) (250/max=1000000), gen(at_category)

*at_category2 (for IRS audit probability)
recode at (0/0.25=0.25) (0.25/1=1) (1/5=5) (5/10=10) (10/50=50) (50/100=100) (100/250=250) (250/500=500) (500/1000=1000) (1000/5000=5000) (5000/20000=20000) (20000/1000000=1000000) (1000000/max=9999999), gen(at_category2)

replace at_category2=at_category if fyear>0 & fyear<=2006

**********************************************************************************
***merge 10-X Parse Data from Bill Mcdonald to obtain historical HQ information***
**********************************************************************************

mer 1:1 cik fyear using "C:\Users\LoughranMcDonald_10-K_HeaderData.dta"
drop if _merge==2
rename _merge _mer_cstat_10k

gen ba_state2=ba_state
replace ba_state2=state if ba_state==""

gen ba_state_fips=0
replace ba_state_fips=1 if ba_state2=="AL"
replace ba_state_fips=2 if ba_state2=="AK"
replace ba_state_fips=4 if ba_state2=="AZ"
replace ba_state_fips=5 if ba_state2=="AR"
replace ba_state_fips=6 if ba_state2=="CA"
replace ba_state_fips=8 if ba_state2=="CO"
replace ba_state_fips=9 if ba_state2=="CT"
replace ba_state_fips=10 if ba_state2=="DE"
replace ba_state_fips=11 if ba_state2=="DC"
replace ba_state_fips=12 if ba_state2=="FL"
replace ba_state_fips=13 if ba_state2=="GA"
replace ba_state_fips=15 if ba_state2=="HI"
replace ba_state_fips=16 if ba_state2=="ID"
replace ba_state_fips=17 if ba_state2=="IL"
replace ba_state_fips=18 if ba_state2=="IN"
replace ba_state_fips=19 if ba_state2=="IA"
replace ba_state_fips=20 if ba_state2=="KS"
replace ba_state_fips=21 if ba_state2=="KY"
replace ba_state_fips=22 if ba_state2=="LA"
replace ba_state_fips=23 if ba_state2=="ME"
replace ba_state_fips=24 if ba_state2=="MD"
replace ba_state_fips=25 if ba_state2=="MA"
replace ba_state_fips=26 if ba_state2=="MI"
replace ba_state_fips=27 if ba_state2=="MN"
replace ba_state_fips=28 if ba_state2=="MS"
replace ba_state_fips=29 if ba_state2=="MO"
replace ba_state_fips=30 if ba_state2=="MT"
replace ba_state_fips=31 if ba_state2=="NE"
replace ba_state_fips=32 if ba_state2=="NV"
replace ba_state_fips=33 if ba_state2=="NH"
replace ba_state_fips=34 if ba_state2=="NJ"
replace ba_state_fips=35 if ba_state2=="NM"
replace ba_state_fips=36 if ba_state2=="NY"
replace ba_state_fips=37 if ba_state2=="NC"
replace ba_state_fips=38 if ba_state2=="ND"
replace ba_state_fips=39 if ba_state2=="OH"
replace ba_state_fips=40 if ba_state2=="OK"
replace ba_state_fips=41 if ba_state2=="OR"
replace ba_state_fips=42 if ba_state2=="PA"
replace ba_state_fips=44 if ba_state2=="RI"
replace ba_state_fips=45 if ba_state2=="SC"
replace ba_state_fips=46 if ba_state2=="SD"
replace ba_state_fips=47 if ba_state2=="TN"
replace ba_state_fips=48 if ba_state2=="TX"
replace ba_state_fips=49 if ba_state2=="UT"
replace ba_state_fips=50 if ba_state2=="VT"
replace ba_state_fips=51 if ba_state2=="VA"
replace ba_state_fips=53 if ba_state2=="WA"
replace ba_state_fips=54 if ba_state2=="WV"
replace ba_state_fips=55 if ba_state2=="WI"
replace ba_state_fips=56 if ba_state2=="WY"

gen state_fips=ba_state_fips


ds
keep `r(varlist)'
keep gvkey cik fyear fyr fic datadate datayear year state ba_state ba_state2 ba_state_fips state_fips naics sic sich sic2h sic2hy sic3h sic3hy fin at sale prcc_f csho ceq dltt at_lag1 sale_lag1 tlcf_lag1 invt invt0 xrd xrd0 ppent ppent0 intan intan0 pifo pifo0 xad xad0 xsga xsga0 mii mii0 esub esub0 ln_at mb dltt_at invt0_at xrd0_at ppent0_at intan0_at roa_oi pifo0_at fi0 max_fi0 xad0_at sale_growth sale0_growth xsga0_at nol0 tlcf ch_nol ch_nol0 ch_nol0_at esub0_at mii0_at pidom pidom0 pi pifo pifo0 txww txfed txfo txt txdfed fedtax fedetr fedetr1 fedetrww fedetrww1 zipcode at_category at_category2 _mer_cstat_10k

winsor2 ln_at mb dltt_at invt0_at xrd0_at ppent0_at intan0_at roa_oi pifo0_at fi0 xad0_at sale0_growth xsga0_at nol ch_nol0_at mii0_at esub0_at



***********************************************************************************************
***[for creation of pseudo dataset only] incorporate random noise into the control variables***
***********************************************************************************************
local continuous_vars ln_at mb_w dltt_at_w invt0_at_w xrd0_at_w ppent0_at_w intan0_at_w roa_oi_w pifo0_at_w fi0 xad0_at_w sale0_growth_w xsga0_at_w nol0 ch_nol0_at_w mii0_at_w esub0_at_w at prcc_f csho ceq 

foreach var of local continuous_vars {
    replace `var' = `var' * (1 + runiform(-x, x))
}

*************************************************************************************
***[for creation of pseudo dataset only] map gvkey with Pseudo ID and remove gvkey***
*************************************************************************************

merge m:1 gvkey cik fyear using "C:\Users\mapping_gvkey_cik_pseudo.dta"

keep if _merge==3
rename _merge _merge_pseudo_id
***********************************************************
***********************************************************
***********************************************************



*********************************
***HQ zipcode, county, and MSA***
*********************************
sort gvkey fyear
mer 1:1 gvkey fyear using "C:\Users\cstat_zipcode.dta", update
drop if _merge==2
rename _merge _mer_cstat_zip_update


mer m:1 zipcode using "C:\Users\zip_state_county_msa.dta"
drop if _merge==2
rename _merge _mer_zipcode_msa

gen ba_state_county_fips=ba_state_fips*1000 + countyno


**************************
***merge State GDP data***
**************************
sort state_fips year
mer m:1 state_fips year using "C:\Users\state_gsp_1963_2018.dta"
drop if _merge==2
rename _merge _mer_state_gsp


***********************************
***merge State unemployment data***
***********************************
sort state_fips year
mer m:1 state_fips year using "C:\Users\state_unemp_1980_2018.dta"
drop if _merge==2
rename _merge _mer_state_unemp


*******************************
***merge State election data***
*******************************
sort state_fips year
mer m:1 state_fips year using "C:\Users\us_presidents_vote_bluestate.dta"
drop if _merge==2
rename _merge _mer_USpresident_vote


***************************************************************
***merge IRS probability data (based on asset size category)***
***************************************************************
sort at_category2 fyear 
mer m:1 at_category2 fyear using "C:\Users\irs_auditprob.dta"
drop if _merge==2
rename _merge _mer_irsauditprob



***********************************************
***merge IRS download data (using pseudo id)***
***********************************************
sort pseudoid year
mer 1:1 pseudoid year using "C:\Users\pseudo_irs_download.dta"
drop if _merge==2
rename _merge _mer_irsattention_fox

gen irsattention0=irs_download_all
replace irsattention0=0 if irs_download_all==.

gen irsattention_missing=0
replace irsattention_missing=1 if irs_download_all==.
***********************************************


*******************************************************************************************
***[for creation of pseudo dataset only] create a randomized sample from the full sample***
*******************************************************************************************
set seed xxxxxx
gen u = runiform()
sort u
keep if u < 0.35
drop u

local controls ln_at mb_w dltt_at_w invt0_at_w xrd0_at_w ppent0_at_w intan0_at_w roa_oi_w pifo0_at_w fi0 xad0_at_w sale0_growth_w xsga0_at_w nol0 ch_nol0_at_w mii0_at_w esub0_at_w auditprob irsattention0 irsattention_missing gsp_growth unemp blue_state

reghdfe fedetr1 `controls' if fyear>=1996 & fyear<=2016 & at>10 & at<99999999999999 & fin==0 & fic=="USA", a(msano sic2hy) cluster(ba_state2 datayear)

drop gvkey cik
order pseudoid
keep if e(sample)==1
***************************************************
***************************************************
***************************************************

*save "C:\Users\pseudo_compustat_controls.dta"


****************************************************
***merge Circuit, Tax and District Court Ideology***
****************************************************

gen modate=ym(fyear, fyr)
format modate %tm
gen modate_merge=modate-11
format modate_merge %tm
sort ba_state2 modate_merge
mer m:1 ba_state2 modate_merge using "C:\Users\circuit_judge_ideology_sas7bdat_date.dta"
drop if _merge==2
rename _merge _mer_cstat_10k_judge

tempvar yearm1
gen `yearm1' = year - 1

rename year year_orig
rename `yearm1' year

sort modate_merge year
mer m:1 modate_merge using "C:\Users\tax_judge_ideology_sas7bdat.dta"
drop if _merge==2
rename _merge _mer_taxcourt_ideology

sort ba_state_county_fips year
merge m:1 ba_state_county_fips year using "C:\Users\district_judge_ideology_county_year.dta"
drop if _merge == 2
rename _merge _mer_districtcourt_ideology

rename year `yearm1'
rename year_orig year
drop `yearm1'

quietly reghdfe fedetr1 liberal_court tax_liberal_court liberal_district ln_at_w mb_w dltt_at_w invt0_at_w xrd0_at_w ppent0_at_w intan0_at_w roa_oi_w pifo0_at_w fi0 xad0_at_w sale0_growth_w xsga0_at_w nol0 ch_nol0_at_w mii0_at_w esub0_at_w auditprob irsattention_missing gsp_growth unemp blue_state if fyear>=1996 & fyear<=2016 & at>10 & at<99999999999999 & fin==0 & fic=="USA" , a(msano sic3hy) cluster(ba_state2 datayear)

bys year: astile auditprob_nq4=auditprob if e(sample)==1, nq(4)
bys year: astile irsattention0_nq4=irsattention0, nq(4)



**************************
***Table 3 Main Results***
**************************

local controls ln_at mb_w dltt_at_w invt0_at_w xrd0_at_w ppent0_at_w intan0_at_w roa_oi_w pifo0_at_w fi0 xad0_at_w sale0_growth_w xsga0_at_w nol0 ch_nol0_at_w mii0_at_w esub0_at_w auditprob_nq4 irsattention0_nq4 irsattention_missing gsp_growth unemp blue_state

reghdfe fedetr1 liberal_court `controls' if fyear>=1996 & fyear<=2016 & at>10 & at<99999999999999 & fin==0 & fic=="USA" & liberal_district<. & tax_liberal_court<., a(msano sic2hy) cluster(ba_state2 datayear)
*outreg2 using Pseudo_Judge2026_Table3.xls, excel bdec(4) tstat tdec(2) rdec(2) symbol(***,**,*) addstat(Adjusted R-squared, e(r2_a))

reghdfe fedetr1 tax_liberal_court `controls' if fyear>=1996 & fyear<=2016 & at>10 & at<99999999999999 & fin==0 & fic=="USA" & liberal_district<. & tax_liberal_court<., a(msano sic2hy) cluster(ba_state2 datayear)
*outreg2 using Pseudo_Judge2026_Table3.xls, excel bdec(4) tstat tdec(2) rdec(2) symbol(***,**,*) addstat(Adjusted R-squared, e(r2_a))

reghdfe fedetr1 liberal_district `controls' if fyear>=1996 & fyear<=2016 & at>10 & at<99999999999999 & fin==0 & fic=="USA" & liberal_district<. & tax_liberal_court<., a(msano sic2hy) cluster(ba_state2 datayear)
*outreg2 using Pseudo_Judge2026_Table3.xls, excel bdec(4) tstat tdec(2) rdec(2) symbol(***,**,*) addstat(Adjusted R-squared, e(r2_a))

reghdfe fedetr1 liberal_court tax_liberal_court liberal_district `controls' if fyear>=1996 & fyear<=2016 & at>10 & at<99999999999999 & fin==0 & fic=="USA" & liberal_district<. & tax_liberal_court<., a(msano sic2hy) cluster(ba_state2 datayear)
*outreg2 using Pseudo_Judge2026_Table3.xls, excel bdec(4) tstat tdec(2) rdec(2) symbol(***,**,*) addstat(Adjusted R-squared, e(r2_a))


*save "C:\Users\pseudo_random1_analysis.dta"



********************************
***Table 2 Summary Statistics***
********************************

*asdoc sum fedetr1 liberal_court tax_liberal_court liberal_district ln_at mb_w dltt_at_w invt0_at_w xrd0_at_w ppent0_at_w intan0_at_w roa_oi_w pifo0_at_w fi0 xad0_at_w sale0_growth_w xsga0_at_w nol0 ch_nol0_at_w mii0_at_w esub0_at_w auditprob_nq4 irsattention0_nq4 irsattention_missing gsp_growth unemp blue_state if e(sample)==1, stat(N mean sd p25 median p75) replace



**********************
***Table 4, Panel A***
**********************

clear
use "C:\Users\pseudo_random1_analysis.dta"

mer 1:1 pseudoid fyear using "C:\Users\pseudo_shiftout.dta"
drop if _merge==2
rename _merge _mer_shiftout

gen lib_shifters_out5=liberal_court*shifters_out5

drop auditprob_nq4 irsattention0_nq4
quietly reg fedetrww1 liberal_court shifters_out5 ln_at mb_w dltt_at_w invt0_at_w xrd0_at_w ppent0_at_w intan0_at_w roa_oi_w pifo0_at_w fi0 xad0_at_w sale0_growth_w xsga0_at_w nol0 ch_nol0_at_w mii0_at_w esub0_at_w auditprob irsattention0 irsattention_missing gsp_growth unemp blue_state
bys year: astile auditprob_nq4=auditprob if _mer_shiftout==3, nq(4)
bys year: astile irsattention0_nq4=irsattention0 if _mer_shiftout==3, nq(4)

local controls ln_at mb_w dltt_at_w invt0_at_w xrd0_at_w ppent0_at_w intan0_at_w roa_oi_w pifo0_at_w fi0 xad0_at_w sale0_growth_w xsga0_at_w nol0 ch_nol0_at_w mii0_at_w esub0_at_w auditprob_nq4 irsattention0_nq4 irsattention_missing gsp_growth unemp blue_state

reghdfe fedetrww1 lib_shifters_out5 shifters_out5 liberal_court `controls' if fyear>=1996 & fyear<=2016 & at>10 & at<99999999999999 & fin==0 & fic=="USA" & liberal_district<. & tax_liberal_court<., a(msano sic2hy) cluster(ba_state2 datayear)
*outreg2 using Pseudo_Judge2026_Table4_PanelA.xls, excel bdec(4) tstat tdec(2) rdec(2) symbol(***,**,*) addstat(Adjusted R-squared, e(r2_a))



**********************
***Table 4, Panel A***
**********************

clear
use "C:\Users\pseudo_random1_analysis.dta"

sort pseudoid fyear
mer 1:1 pseudoid fyear using "C:\Users\pseudo_tax_haven.dta"

drop if _merge==2
rename _merge _mer_tax_haven

gen totalhavencount0=totalhavencount 
replace totalhavencount0=0 if totalhavencount0==.

gen lntotalhavencount0=ln(1 + totalhavencount0)
gen lib_lnnhaven=liberal_court*lntotalhavencount0

local controls ln_at mb_w dltt_at_w invt0_at_w xrd0_at_w ppent0_at_w intan0_at_w roa_oi_w pifo0_at_w fi0 xad0_at_w sale0_growth_w xsga0_at_w nol0 ch_nol0_at_w mii0_at_w esub0_at_w auditprob_nq4 irsattention0_nq4 irsattention_missing gsp_growth unemp blue_state

reghdfe fedetrww1 lib_lnnhaven lntotalhavencount0 liberal_court `controls' if fyear>=1996 & fyear<=2016 & at>10 & at<99999999999999 & fic=="USA" & liberal_district<. & tax_liberal_court<. & max_fi0==1, a(msano sic2hy) cluster(ba_state2 datayear)
*outreg2 using Pseudo_Judge2026_Table4_PanelA.xls, excel bdec(4) tstat tdec(2) rdec(2) symbol(***,**,*) addstat(Adjusted R-squared, e(r2_a))



**********************
***Table 4, Panel A***
**********************

clear
use "C:\Users\pseudo_random1_analysis.dta"


***use compustat NAICS to match with IRS SOI industry classifications
gen naics3h=int(naics/1000)
replace naics3h=int(naics*10) if naics>0 & naics<100
replace naics3h=int(naics) if naics>100 & naics<1000
replace naics3h=int(naics/10) if naics>1000 & naics<10000
replace naics3h=int(naics/100) if naics>10000 & naics<100000
egen naics3hy=group(naics3h datayear)

gen indy_cd=naics3h
replace indy_cd=21 if inrange(naics3h, 211, 213)
replace indy_cd=22 if inrange(naics3h, 221, 229)
replace indy_cd=41 if inrange(naics3h, 411, 419)
replace indy_cd=46 if inrange(naics3h, 461, 469)
replace indy_cd=61 if inrange(naics3h, 610, 619)
replace indy_cd=90 if naics3h==999
egen indy_cd_year=group(indy_cd datayear)


***define asset size category
gen ac=3 if at>=1 & at<500
replace ac=4 if at>=500 & at<1000
replace ac=5 if at>=1000 & at<5000
replace ac=6 if at>=5000 & at<10000
replace ac=7 if at>=10000 & at<25000
replace ac=8 if at>=25000 & at<50000
replace ac=9 if at>=50000 & at<100000
replace ac=10 if at>=100000 & at<250000
replace ac=11 if at>=250000 & at<500000
replace ac=12 if at>=500000 & at<2500000
replace ac=13 if at>=2500000 & at<999999999999
replace ac=2 if ac==.


mer m:1 ac year indy_cd using "C:\Users\pseudo_soi_sb.dta" 
drop if _merge==2
rename _merge _mer_dpad_05_13sb2

drop dpad_intensity
gen dpad_intensity=qpai_percent*dpad_rate
gen lib_dpadinten=dpad_intensity*liberal_court

***restrict sample to fyear>=2005 & fyear<=2013
local controls ln_at mb_w dltt_at_w invt0_at_w xrd0_at_w ppent0_at_w intan0_at_w roa_oi_w pifo0_at_w fi0 xad0_at_w sale0_growth_w xsga0_at_w nol0 ch_nol0_at_w mii0_at_w esub0_at_w auditprob_nq4 irsattention0_nq4 irsattention_missing gsp_growth unemp blue_state

reghdfe fedetr1 lib_dpadinten dpad_intensity liberal_court `controls' if fyear>=2005 & fyear<=2013 & at>10 & at<99999999999999 & fin==0 & fic=="USA" & liberal_district<. & tax_liberal_court<., a(msano indy_cd_year) cluster(ba_state2 datayear)
*outreg2 using Pseudo_Judge2026_Table4_PanelA.xls, excel bdec(4) tstat tdec(2) rdec(2) symbol(***,**,*) addstat(Adjusted R-squared, e(r2_a))



**********************
***Table 4, Panel A***
**********************

clear
use "C:\Users\pseudo_random1_analysis.dta"

mer 1:1 pseudoid year using "C:\Users\pseudo_rd_credits.dta"
drop if _merge==2
rename _merge _mer_rd

gen rd0=0
replace rd0=1 if _rd==1
gen lib_rd0=liberal_court*rd0

***restrict sample to fyear>=2000
local controls ln_at mb_w dltt_at_w invt0_at_w xrd0_at_w ppent0_at_w intan0_at_w roa_oi_w pifo0_at_w fi0 xad0_at_w sale0_growth_w xsga0_at_w nol0 ch_nol0_at_w mii0_at_w esub0_at_w auditprob_nq4 irsattention0_nq irsattention_missing gsp_growth unemp blue_state

reghdfe fedetr1 lib_rd0 rd0 liberal_court `controls' if fyear>=2000 & fyear<=2016 & at>10 & at<99999999999999 & fin==0 & fic=="USA" & liberal_district<. & tax_liberal_court<., a(msano sic2hy) cluster(ba_state2 datayear)
*outreg2 using Pseudo_Judge2026_Table4_PanelA.xls, excel bdec(4) tstat tdec(2) rdec(2) symbol(***,**,*) addstat(Adjusted R-squared, e(r2_a))



**********************
***Table 4, Panel B***
**********************

clear
use "C:\Users\pseudo_random1_analysis.dta"

local controls ln_at mb_w dltt_at_w invt0_at_w xrd0_at_w ppent0_at_w intan0_at_w roa_oi_w pifo0_at_w fi0 xad0_at_w sale0_growth_w xsga0_at_w nol0 ch_nol0_at_w mii0_at_w esub0_at_w auditprob_nq4 irsattention0_nq4 irsattention_missing gsp_growth unemp blue_state
quietly reghdfe fedetr1 liberal_court `controls' if fyear>=1996 & fyear<=2016 & at>10 & at<99999999999999 & fin==0 & fic=="USA" & liberal_district<. & tax_liberal_court<., a(msano sic2hy) cluster(ba_state2 datayear)
gen esample=1 if e(sample)==1

gen irs_download_missing=0
replace irs_download_missing=1 if irs_download_all==.

gen irs_download_all0=irs_download_all
replace irs_download_all0=0 if irs_download_all==.


quietly reg fedetr1 liberal_court ln_at mb_w dltt_at_w invt0_at_w xrd0_at_w ppent0_at_w intan0_at_w roa_oi_w pifo0_at_w fi0 xad0_at_w sale0_growth_w xsga0_at_w nol0 ch_nol0_at_w mii0_at_w esub0_at_w auditprob irsattention0 irsattention_missing gsp_growth unemp blue_state
bys year: astile high_irsauditprob=auditprob if e(sample)==1, nq(2)
replace high_irsauditprob=high_irsauditprob - 1
gen lib_irsaudit=liberal_court*high_irsauditprob

bys year: astile high_irs_download_all0=irs_download_all0 if e(sample)==1, nq(2)
replace high_irs_download_all0=high_irs_download_all0 - 1
gen lib_irs_download_all0=liberal_court*high_irs_download_all0


local controls ln_at mb_w dltt_at_w invt0_at_w xrd0_at_w ppent0_at_w intan0_at_w roa_oi_w pifo0_at_w fi0 xad0_at_w sale0_growth_w xsga0_at_w nol0 ch_nol0_at_w mii0_at_w esub0_at_w high_irsauditprob irsattention0_nq4 irsattention_missing gsp_growth unemp blue_state

reghdfe fedetr1 lib_irsaudit liberal_court `controls' if fyear>=1996 & fyear<=2016 & at>10 & at<99999999999999 & fin==0 & fic=="USA" & liberal_district<. & tax_liberal_court<. & esample==1 , a(msano sic2hy) cluster(ba_state2 datayear)
*outreg2 using Pseudo_Judge2026_Table4_PanelB.xls, excel bdec(4) tstat tdec(2) rdec(2) symbol(***,**,*) addstat(Adjusted R-squared, e(r2_a))


***restrict sample to fyear>=2003
local controls ln_at mb_w dltt_at_w invt0_at_w xrd0_at_w ppent0_at_w intan0_at_w roa_oi_w pifo0_at_w fi0 xad0_at_w sale0_growth_w xsga0_at_w nol0 ch_nol0_at_w mii0_at_w esub0_at_w auditprob_nq4 high_irs_download_all0 irsattention_missing gsp_growth unemp blue_state

reghdfe fedetr1 lib_irs_download_all0 liberal_court `controls' if fyear>=2003 & fyear<=2016 & at>10 & at<99999999999999 & fin==0 & fic=="USA" & liberal_district<. & tax_liberal_court<., a(msano sic2hy) cluster(ba_state2 datayear)
*outreg2 using Pseudo_Judge2026_Table4_PanelB.xls, excel bdec(4) tstat tdec(2) rdec(2) symbol(***,**,*) addstat(Adjusted R-squared, e(r2_a))



**********************
***Table 4, Panel B***
**********************

clear
use "C:\Users\pseudo_random1_analysis.dta"

mer m:1 sich using "C:\Users\industries_ff48h_sich.dta"
drop _merge

egen ff48hy=group(ff48h datayear)

gen high_reput_concern = inlist(ff48h, 2, 3, 6, 9, 10, 23, 33, 42, 43)
gen lib_high_reput=liberal_court*high_reput_concern

local controls ln_at mb_w dltt_at_w invt0_at_w xrd0_at_w ppent0_at_w intan0_at_w roa_oi_w pifo0_at_w fi0 xad0_at_w sale0_growth_w xsga0_at_w nol0 ch_nol0_at_w mii0_at_w esub0_at_w auditprob_nq4 irsattention0_nq4 irsattention_missing gsp_growth unemp blue_state

reghdfe fedetr1 lib_high_reput high_reput_concern liberal_court `controls' if fyear>=1996 & fyear<=2016 & at>10 & at<99999999999999 & fin==0 & fic=="USA" & liberal_district<. & tax_liberal_court<., a(msano ff48hy) cluster(ba_state2 datayear)
*outreg2 using Pseudo_Judge2026_Table4_PanelB.xls, excel bdec(4) tstat tdec(2) rdec(2) symbol(***,**,*) addstat(Adjusted R-squared, e(r2_a))



*************
***Table 5***
*************

clear
use "C:\Users\pseudo_random1_analysis.dta"

local controls ln_at mb_w dltt_at_w invt0_at_w xrd0_at_w ppent0_at_w intan0_at_w roa_oi_w pifo0_at_w fi0 xad0_at_w sale0_growth_w xsga0_at_w nol0 ch_nol0_at_w mii0_at_w esub0_at_w auditprob_nq4 irsattention0_nq4 irsattention_missing gsp_growth unemp blue_state

quietly reghdfe fedetr1 liberal_court `controls' if fyear>=1996 & fyear<=2016 & at>10 & at<99999999999999 & fin==0 & fic=="USA" & liberal_district<. & tax_liberal_court<., a(msano sic2hy) cluster(ba_state2 datayear)

keep if e(sample)==1
gen q=(at+prcc_f*csho-ceq)/at
winsor2 q

local controls ln_at mb_w dltt_at_w invt0_at_w ppent0_at_w intan0_at_w roa_oi_w pifo0_at_w fi0 xad0_at_w sale0_growth_w xsga0_at_w nol0 ch_nol0_at_w mii0_at_w esub0_at_w auditprob_nq4 irsattention0_nq4 irsattention_missing gsp_growth unemp blue_state

sgmediation2 xrd0_at_w, iv(liberal_court) mv(fedetr1) cv(`controls' i.msano i.sic2hy)
return list

local controls ln_at mb_w dltt_at_w invt0_at_w xrd0_at_w ppent0_at_w intan0_at_w roa_oi_w pifo0_at_w fi0 xad0_at_w sale0_growth_w xsga0_at_w nol0 ch_nol0_at_w mii0_at_w esub0_at_w auditprob_nq4 irsattention0_nq4 irsattention_missing gsp_growth unemp blue_state

sgmediation2 q_w, iv(liberal_court) mv(fedetr1) cv(`controls' i.msano i.sic2hy)
return list



*************
***Table 6***
*************

clear
use "C:\Users\pseudo_random1_analysis.dta"

sort gvkey fyear
by gvkey: gen fedetr1_lag1=fedetr1[_n-1]
by gvkey: gen fedetr1_lag2=fedetr1[_n-2]
by gvkey: gen fedetr1_lag3=fedetr1[_n-3]

egen sd3_fedetr1=rowsd(fedetr1_lag1 fedetr1_lag2 fedetr1_lag3)

quietly reghdfe fedetr1 liberal_court tax_liberal_court liberal_district ln_at_w mb_w dltt_at_w invt0_at_w xrd0_at_w ppent0_at_w intan0_at_w roa_oi_w pifo0_at_w fi0 xad0_at_w sale0_growth_w xsga0_at_w nol0 ch_nol0_at_w mii0_at_w esub0_at_w auditprob_nq4 irsattention0_nq4 irsattention_missing gsp_growth unemp blue_state if fyear>=1996 & fyear<=2016 & at>10 & at<99999999999999 & fin==0 & fic=="USA" & liberal_district<. & tax_liberal_court<., a(msano sic2hy) cluster(ba_state2 datayear)

sum sd3_fedetr1 if e(sample)==1,detail

gen high_tax_risk=0
replace high_tax_risk=1 if sd3_fedetr1>0.031 & sd3_fedetr1<999999999
replace high_tax_risk=. if sd3_fedetr1==.
gen lib_high_taxrisk=liberal_court*high_tax_risk

local controls ln_at mb_w dltt_at_w invt0_at_w xrd0_at_w ppent0_at_w intan0_at_w roa_oi_w pifo0_at_w fi0 xad0_at_w sale0_growth_w xsga0_at_w nol0 ch_nol0_at_w mii0_at_w esub0_at_w auditprob_nq4 irsattention0_nq4 irsattention_missing gsp_growth unemp blue_state

reghdfe fedetr1 lib_high_taxrisk high_tax_risk liberal_court `controls' if fyear>=1996 & fyear<=2016 & at>10 & at<99999999999999 & fin==0 & fic=="USA" & liberal_district<. & tax_liberal_court<., a(msano sic2hy) cluster(ba_state2 datayear)
*outreg2 using Pseudo_Judge2026_Table6.xls, excel bdec(4) tstat tdec(2) rdec(2) symbol(***,**,*) addstat(Adjusted R-squared, e(r2_a))



*************
***Table 6***
*************

clear
use "C:\Users\pseudo_random1_analysis.dta"

mer 1:1 pseudoid fyear using "C:\Users\pseudo_foreign_sales.dta"
drop if _merge==2
rename _merge _mer_geoseg

quietly reghdfe fedetr1 liberal_court `controls' if fyear>=1996 & fyear<=2016 & at>10 & at<99999999999999 & fin==0 & fic=="USA" & liberal_district<. & tax_liberal_court<., a(msano sic2hy) cluster(ba_state2 datayear)
egen med_for_sales_ratio=median(for_sales_ratio) if e(sample)==1 & for_sales_ratio>0 & for_sales_ratio<.
gen above_median_for_sales_ratio=for_sales_ratio> med_for_sales_ratio if e(sample)==1 & for_sales_ratio>0 & for_sales_ratio<.
gen lib_high_for_sales_ratio=liberal_court*above_median_for_sales_ratio

local controls ln_at mb_w dltt_at_w invt0_at_w xrd0_at_w ppent0_at_w intan0_at_w roa_oi_w pifo0_at_w fi0 xad0_at_w sale0_growth_w xsga0_at_w nol0 ch_nol0_at_w mii0_at_w esub0_at_w auditprob_nq4 irsattention0_nq irsattention_missing gsp_growth unemp blue_state

reghdfe fedetr1 lib_high_for_sales_ratio above_median_for_sales_ratio liberal_court `controls' if fyear>=1996 & fyear<=2016 & at>10 & at<99999999999999 & fin==0 & fic=="USA" & liberal_district<. & tax_liberal_court<., a(msano sic2hy) cluster(ba_state2 datayear)
*outreg2 using Pseudo_Judge2026_Table6.xls, excel bdec(4) tstat tdec(2) rdec(2) symbol(***,**,*) addstat(Adjusted R-squared, e(r2_a))



*************
***Table 7***
*************

clear
use "C:\Users\pseudo_random1_analysis.dta"

gen courtid=.
replace courtid=1 if circuit=="C1"
replace courtid=2 if circuit=="C2"
replace courtid=3 if circuit=="C3"
replace courtid=4 if circuit=="C4"
replace courtid=5 if circuit=="C5"
replace courtid=6 if circuit=="C6"
replace courtid=7 if circuit=="C7"
replace courtid=8 if circuit=="C8"
replace courtid=9 if circuit=="C9"
replace courtid=10 if circuit=="C10"
replace courtid=11 if circuit=="C11"
replace courtid=12 if circuit=="DC"
replace courtid=13 if circuit=="Federal"

sort courtid year
mer m:1 courtid year using "C:\Users\pseudo_court_year_data.dta"
drop if _merge==2
rename _merge _mer_judge_panel

sum WellQualified_rate avg_workyear avg_age, detail

gen high_wellq=0
replace high_wellq=1 if WellQualified_rate>=0.61 & WellQualified_rate<=1

gen high_exp=0
replace high_exp=1 if avg_workyear>=16 & avg_workyear<=99

gen high_age=0
replace high_age=1 if avg_age>=66.5 & avg_age<=99

gen lib_highwellq=liberal_court*high_wellq
gen lib_highexp=liberal_court*high_exp
gen lib_highage=liberal_court*high_age

gen female01=0
replace female01=1 if female_count>0 & female_count<=1
gen lib_female01=liberal_court*female01

local controls ln_at mb_w dltt_at_w invt0_at_w xrd0_at_w ppent0_at_w intan0_at_w roa_oi_w pifo0_at_w fi0 xad0_at_w sale0_growth_w xsga0_at_w nol0 ch_nol0_at_w mii0_at_w esub0_at_w auditprob_nq4 irsattention0_nq4 irsattention_missing gsp_growth unemp blue_state

reghdfe fedetr1 lib_highwellq high_wellq liberal_court `controls' if fyear>=1996 & fyear<=2016 & at>10 & at<99999999999999 & fin==0 & fic=="USA" & liberal_district<. & tax_liberal_court<., a(msano sic2hy) cluster(ba_state2 datayear)
lincom lib_highwellq + liberal_court
*outreg2 using Pseudo_Judge2026_Table7.xls, excel bdec(4) tstat tdec(2) rdec(2) symbol(***,**,*) addstat(Adjusted R-squared, e(r2_a))

reghdfe fedetr1 lib_highexp high_exp liberal_court `controls' if fyear>=1996 & fyear<=2016 & at>10 & at<99999999999999 & fin==0 & fic=="USA" & liberal_district<. & tax_liberal_court<., a(msano sic2hy) cluster(ba_state2 datayear)
lincom lib_highexp + liberal_court 
*outreg2 using Pseudo_Judge2026_Table7.xls, excel bdec(4) tstat tdec(2) rdec(2) symbol(***,**,*) addstat(Adjusted R-squared, e(r2_a))

reghdfe fedetr1 lib_highage high_age liberal_court `controls' if fyear>=1996 & fyear<=2016 & at>10 & at<99999999999999 & fin==0 & fic=="USA" & liberal_district<. & tax_liberal_court<., a(msano sic2hy) cluster(ba_state2 datayear)
lincom lib_highage + liberal_court 
*outreg2 using Pseudo_Judge2026_Table7.xls, excel bdec(4) tstat tdec(2) rdec(2) symbol(***,**,*) addstat(Adjusted R-squared, e(r2_a))

reghdfe fedetr1 lib_female01 female01 liberal_court  `controls' if fyear>=1996 & fyear<=2016 & at>10 & at<99999999999999 & fin==0 & fic=="USA" & liberal_district<. & tax_liberal_court<., a(msano sic2hy) cluster(ba_state2 datayear)
lincom lib_female01 + liberal_court 
*outreg2 using Pseudo_Judge2026_Table7.xls, excel bdec(4) tstat tdec(2) rdec(2) symbol(***,**,*) addstat(Adjusted R-squared, e(r2_a))













